import { defineConfig } from '@vben/vite-config';

export default defineConfig(async () => {
  const authTargetServer = 'http://192.168.19.232:1010';
  const authProxyPaths = ['/users', '/role', '/client', '/groups', '/permissions', '/resources', '/scopes', '/user-identities', '/organizations'];

  const proxy = authProxyPaths.reduce((acc, path) => {
    acc[path] = {
      target: authTargetServer,
      changeOrigin: true,
      ws: true,
    };
    return acc;
  }, {
    '/model-lake': {
      changeOrigin: true,
      rewrite: (path: string) => path.replace(/^\/model-lake/, ''),
      target: 'http://192.168.19.232:8888/model-lake',
      ws: true,
    },
    '/api': {
      changeOrigin: true,
      rewrite: (path: string) => path.replace(/^\/api/, ''),
      target: 'http://192.168.19.232:8088/api',
      ws: true,
    },
  } as Record<string, any>);

  return {
    application: {},
    vite: {
      server: {
        proxy,
      },
    },
    // ...其他配置
  };
});
